package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.CourseReply;
import com.hl.sfzy.mapper.CourseReplyMapper;
import com.hl.sfzy.service.CourseReplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CourseReplyServiceImpl implements CourseReplyService {

    @Autowired
    private CourseReplyMapper courseReplyMapper;
    @Override
    public int removeByPrimaryKey(Long id) {
        return courseReplyMapper.deleteByPrimaryKey(id);
    }

    @Override
    public int add(CourseReply courseReply) {
        return courseReplyMapper.insert(courseReply);
    }

    @Override
    public CourseReply findByPrimaryKey(Long id) {
        return courseReplyMapper.selectByPrimaryKey(id);
    }

    @Override
    public int editByPrimaryKey(CourseReply courseReply) {
        return courseReplyMapper.updateByPrimaryKey(courseReply);
    }

    @Override
    public int removeBatch(List<Long> ids) {
        return courseReplyMapper.deleteBatch(ids);
    }

    @Override
    public List<CourseReply> find(int pageNum, int pageSize) {
        return courseReplyMapper.select(pageNum, pageSize);
    }

    @Override
    public PageInfo<CourseReply> findByPage(int pageNum, int pageSize, CourseReply courseReply) {
        PageHelper.startPage(pageNum, pageSize);
        List<CourseReply> list = courseReplyMapper.selectByPage(pageNum, pageSize, courseReply);
        PageInfo<CourseReply> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }
}
